package com.lijinjiang.druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.junit.Test;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.sql.Connection;
import java.util.Properties;

/**
 * @ClassName Demo01
 * @Description TODO
 * @Author Li
 * @Date 2022/9/22 9:00
 * @ModifyDate 2022/9/22 9:00
 * @Version 1.0
 */
public class Demo01 {
    @Test
    public void TestMethod() throws Exception {
        //System.out.println(System.getProperty("user.dir"));

        // 3.加载配置文件
        Properties prop = new Properties();
        prop.load(new FileInputStream("src/druid.properties"));

        // 4.获取连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);

        // 5.获取数据库连接
        Connection conn = dataSource.getConnection();

        System.out.println(conn);
    }
}
